//
//  RHPdfFileCell.m
//  RuiHeAppApp
//
//  Created by Yan Chen on 2023/8/7.
//

#import "RHPdfFileCell.h"
@interface RHPdfFileCell()

@property(nonatomic,strong)UILabel *createTimeLab;
@property(nonatomic,strong)UILabel *fileNameLab;
@property(nonatomic,strong)UILabel *fileSizeLab;
@property(nonatomic,strong)UIView *bgView;
@end
@implementation RHPdfFileCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        [self setupUI];
    }
    return self;
}
-(void)setModel:(RHPdfFileModel *)model
{
    _model = model;
    self.fileNameLab.text = model.fileName;
    self.fileSizeLab.text = model.fileSize;
    self.createTimeLab.text = model.createTime;
}

-(void)setupUI
{
    self.contentView.backgroundColor = CFTabViewBgColor;
    _bgView = [[UIView alloc]init];
    _bgView.layer.cornerRadius = 8;
    _bgView.layer.masksToBounds = YES;
    _bgView.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:_bgView];
    [_bgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.insets(UIEdgeInsetsMake(10, 5, 5, 5));
    }];
    
    UIImageView *iconImg = kImageView;
    iconImg.contentMode = UIViewContentModeCenter;
    iconImg.image = [UIImage imageNamed:@"pdf_icon" ];
    [_bgView addSubview:iconImg];
    [iconImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.mas_offset(10);
            make.width.height.offset(15);
    }];
    
    kWeakSelf;
    self.createTimeLab = kLab;
    self.createTimeLab.text = @"15:00:00";
    self.createTimeLab.textColor = kRGB(120, 120, 120);
    self.createTimeLab.font = [UIFont systemFontOfSize:14];
    self.createTimeLab.textAlignment = NSTextAlignmentLeft;
    [self.bgView addSubview:self.createTimeLab];
    [self.createTimeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.bgView).offset(10);
        make.top.equalTo(iconImg.mas_bottom).offset(10);
        make.bottom.mas_offset(-10);
    }];
    
    
    self.fileNameLab = kLab;
    
    self.fileNameLab.font = [UIFont systemFontOfSize:15];
    self.fileNameLab.text = @"attach file.pdf";
    self.fileNameLab.textAlignment = NSTextAlignmentLeft;
    [_bgView addSubview:self.fileNameLab];
    [self.fileNameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(iconImg.mas_right).offset(10);
        make.centerY.equalTo(iconImg);
    }];
    
    self.fileSizeLab = kLab;
    self.fileSizeLab.text = @"1.5M";
    self.fileSizeLab.font = [UIFont systemFontOfSize:14];
    self.fileSizeLab.textColor = kRGB(180, 180, 180);
    self.fileSizeLab.textAlignment = NSTextAlignmentRight;
    [_bgView addSubview:self.fileSizeLab];
    [self.fileSizeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(_bgView).offset(-10);
        make.centerY.equalTo(_bgView);
    }];
    
   
}
@end
